from django import forms
from django.forms import widgets
from .models import CustomUser


class PersonFrom(forms.ModelForm):
    class Meta:
        model = CustomUser
        fields = ['head','username','email','last_name','first_name']
        widgets = {
            'username': widgets.TextInput(attrs={
                "id": "username",
                "class": "form-control",
            }),
            'email': widgets.TextInput(attrs={
                "id": "email",
                "class": "form-control",
            }),
            'last_name': widgets.TextInput(attrs={
                "id": "last_name",
                "class": "form-control",
            }),
            'first_name': widgets.TextInput(attrs={
                "id": "first_name",
                "class": "form-control",
            })
        }

class UpdatePasswordForm(forms.Form):
    password = forms.CharField(label='密码', widget=forms.PasswordInput(attrs={
        "id": 'password',
        'class': 'form-control',
        'placeholder': '请输入原始密码'

    }))
    password1 = forms.CharField(label='密码', widget=forms.PasswordInput(attrs={
        "id": 'password1',
        'class': 'form-control',
        'placeholder': '请输入新密码'

    }))
    password2 = forms.CharField(label='确认密码', widget=forms.PasswordInput(attrs={
        "id": 'password2',
        'class': 'form-control',
        'placeholder': '请再次确认新密码'

    }))


class LoginForm(forms.Form):
    username = forms.CharField(max_length=150, label='用户名', widget=forms.TextInput(attrs={
        "id": "username",
        "class": "form-control",
        'placeholder': '请输入用户名'
    }))
    password = forms.CharField(label='密码', widget=forms.PasswordInput(attrs={
        "id": 'password',
        'class': 'form-control',
        'placeholder': '请输入密码'

    }))
    password2 = forms.CharField(label='确认密码', widget=forms.PasswordInput(attrs={
        "id": 'password2',
        'class': 'form-control',
        'placeholder': '请再次输入密码'

    }))


class RegistForm(forms.ModelForm):
    password2 = forms.CharField(label='确认密码', widget=forms.PasswordInput(attrs={
        "id": 'password2',
        'class': 'form-control',
        'placeholder': '请再次输入密码'

    }))

    class Meta:
        model = CustomUser
        fields = ['username', 'password', 'email']
        label = {
            'username': '用户名',
            'password': '密码',
            'email': '邮箱',
        }
        widgets = {
            'username': widgets.TextInput(attrs={
                "id": "username",
                "class": "form-control",
                'placeholder': '请输入用户名'
            }),
            'password': widgets.PasswordInput(attrs={
                "id": "password",
                "class": "form-control",
                'placeholder': '请输入密码'
            }),
            'email': widgets.EmailInput(attrs={
                "id": "email",
                "class": "form-control",
                'placeholder': '请输入邮箱'
            })
        }
